package com.jpxx.netty.chaibao2;

import io.netty.buffer.Unpooled;
import io.netty.channel.ChannelHandlerAdapter;
import io.netty.channel.ChannelHandlerContext;

  
public class ServerHandler extends ChannelHandlerAdapter{  

		
		@Override  
	    public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {  
	          System.out.println(ctx.channel().remoteAddress()+"->服务器收到客户端的内容:"+ msg.toString());  
	          ctx.writeAndFlush( Unpooled.copiedBuffer(msg.toString().getBytes())); 
	    }  
	      
	    @Override  
	    public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {  
	        cause.printStackTrace();  
	        ctx.close();  
	    }  
 
	
    
} 